<template>
  <el-dialog
      title="编辑井信息"
      :visible.sync="dialogFormVisible"
      width="30%"
  >
    <el-form :model="form" :rules="rules" ref="formRef" label-width="120px" class="demo-ruleForm">
      <el-form-item label="井名" prop="wellName">
        <el-input v-model="form.well_name" autocomplete="off"/>
      </el-form-item>
      <el-form-item label="坐标X" prop="locx">
        <el-input v-model="form.locx" autocomplete="off"/>
      </el-form-item>
      <el-form-item label="坐标Y" prop="locy">
        <el-input v-model="form.locy" autocomplete="off"/>
      </el-form-item>
      <el-form-item label="补心海拔" prop="kb">
        <el-input v-model="form.kb" autocomplete="off"/>
      </el-form-item>
      <el-form-item label="水深" prop="wd">
        <el-input v-model="form.wd" autocomplete="off"/>
      </el-form-item>
      <el-form-item label="作业单位" prop="workUnit">
        <el-input v-model="form.workUnit" autocomplete="off"/>
      </el-form-item>
      <el-form-item label="操作者" prop="operator">
        <el-input v-model="form.operator" autocomplete="off"/>
      </el-form-item>
    </el-form>
    <span slot="footer" class="dialog-footer">
    <el-button @click="dialogFormVisible = false">取 消</el-button>
    <el-button type="primary" @click="updateWellInfo()">确 定</el-button>
  </span>
  </el-dialog>
</template>
<script>
import api from "@/api/api.js";

export default {
  data() {
    return {
      dialogFormVisible: false,
      form: {
        well_name: '',
        locx: '',
        locy: '',
        kb: '',
        wd: '',
        workUnit: '',
        operator: '',
      },
      rules: {
        well_name: [
          {required: true, message: '请输入井名称', trigger: 'blur'}
        ]
      }
    }
  }, methods: {
    updateWellInfo() {
      api.post("/wellInfo/updateWellInfo", this.form).then(res => {
        if (res.data.code == 0) {
          this.$message({
            message: '更新成功',
            type: 'success'
          })
          this.dialogFormVisible = false;
          this.$parent.getWellInfoList();
        }
      }).catch(err => {
        this.$message({
          message: '更新失败',
          type: 'error'
        })
      })
    }
  }
}
</script>

<style scoped lang="less">

</style>